<template>
    <div>
      <van-goods-action style="position: fixed;z-index: 999;">
        <van-goods-action-icon :icon="isCollected ? 'star' : 'star-o'" :text="isCollected ? '已收藏' : '未收藏'" :color="isCollected ? '#ff5000' : '#333'" @click="isCollected =! isCollected" />
        <van-goods-action-icon icon="cart-o" text="购物车" :badge="goodsCount" color="#333" @click="$router.push('/cart')" />
        <van-goods-action-button type="warning" text="加入购物车" @click="addToCart" />
        <van-goods-action-button type="danger" text="立即购买" @click="handleBuy" />
      </van-goods-action>
    </div>
  </template>
  
  <script>
  export default {
    name: 'GoodActive',
    data () {
      return {
        isCollected: false // 默认不收藏
      }
    },
    props: ['goodsCount'],
    methods: {
      // 立即购买
      handleBuy () {
        this.$toast('功能未开放')
      },
      // 加入购物车
      addToCart () {
        this.$emit('addToCart')
      }
    }
  }
  </script>
  
  <style lang="less" scoped>
  .van-goods-action{
    z-index: 99999;
  }
  </style>
  